﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace App.Utility.Services
{
    public interface IServiceResponse
    {
        bool Successful { get; }
        List<RuleViolation> RuleViolations { get; set; }
    }

    public class ServiceResponse<T> : IServiceResponse
    {
        public List<RuleViolation> RuleViolations { get; set; }

        public ServiceResponse()
        {
            RuleViolations = new List<RuleViolation>();
        }

        public bool Successful
        {
            get { return RuleViolations.Count == 0; }
        }

        public T Response { get; set; }
    }

    public class ServiceResponse : IServiceResponse
    {
        public List<RuleViolation> RuleViolations { get; set; }

        public bool Successful
        {
            get { return RuleViolations.Count == 0; }
        }
    }


    public static class ServiceResponseExtensions
    {
        public static IServiceResponse AppendResponse(this IServiceResponse ServiceResponse,
            IServiceResponse AppendingServiceResponse)
        {
            ServiceResponse.RuleViolations.AddRange(AppendingServiceResponse.RuleViolations);
            return ServiceResponse;
        }
    }
}
